package com.example.easy.Service.Impl;

import com.example.easy.Dto.User;
import com.example.easy.Service.Service.UserService;
import com.example.easy.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper usermapper;


    @Override
    public boolean login(String name, String psd) {
        String sqlpsd = usermapper.selectPsd(name);
        if (sqlpsd == null) {
            return false;
        } else {
            if (psd.equals(usermapper.selectPsd(name))) {
                return true;
            } else {
                return false;
            }
        }
    }

    @Override
    public int regsiter(User u) {
    if(usermapper.selectUid(u.getUser_name())==null){
        //todo 注册
        return  401;
    }else {
      usermapper.insUser(u);
        return 0;
    }


    }

    @Override
    public void updInfo(User u) {
        usermapper.update(u);
    }
}
